package com.example.wangzh.mytest;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;

import com.example.wangzh.mytest.base.BaseActivity;
import com.example.wangzh.mytest.databinding.ActivityAnimatorPathBinding;
import com.example.wangzh.mytest.view.path_animator.AnimatorPath;

public class PathAnimatorActivity extends BaseActivity<ActivityAnimatorPathBinding> {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mBinding.btnStart.setOnClickListener(this::click);
    }

    @SuppressLint("NonConstantResourceId")
    @SuppressWarnings("SwitchStatementWithTooFewBranches")
    void click(View v) {
        switch (v.getId()) {
            case R.id.btn_start:
                startPathAnimation(v);
                break;
            default:
                break;
        }
    }

    private void startPathAnimation(View v) {
        AnimatorPath animatorPath = new AnimatorPath();
        animatorPath.lineTo(100, 100);
        animatorPath.cubicTo(400, 500, 200, 1000, 300, 0);
        animatorPath.lineTo(800, 1000);
        animatorPath.moveTo(100, 100);
        animatorPath.startAnimation(v, 5000);
    }
}
